package com.tengfei.dynamicProxy2;

import com.tengfei.dynamicProxy.UserService;
import com.tengfei.dynamicProxy.UserServiceImpl;
import com.tengfei.dynamicProxy.UserServiceProxy;
import org.junit.Test;

/**
 * @Description:
 * @author: ten_fei
 * @date: 2021-07-09 15:12
 */
public class Client {
    public static void main(String[] args) {
        // 真实角色
        Host host = new Host();

        // 代理角色
        ProxyInvocationHandler pih = new ProxyInvocationHandler();

        // 通过调用程序处理角色来处理我们要调用的接口对象
        pih.setRent(host);

        Rent proxy = (Rent) pih.getProxy();

        proxy.rent();
    }
    @Test
    public void test1(){
        UserServiceImpl userService=new UserServiceImpl();

        InvocationHandlerUtil pih=new InvocationHandlerUtil();

        pih.setTarget(userService);

        UserService proxy = (UserService)pih.getProxy();

        proxy.delete();

    }
}
